#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

#define SIZE 100

typedef int ElmeType;
typedef struct
{
	ElmeType* elme;
	int front;
	int rear;
}SqQueue;

void InitQueue(SqQueue& Q)
{
	Q.elme = (ElmeType*)malloc(sizeof(ElmeType) * SIZE);
	if (!Q.elme)
		exit(-1);
	Q.front = Q.rear = 0;
}

void getLength(SqQueue Q,int & length)
{
	if (Q.front <= Q.rear)
		length = Q.rear - Q.front;
	else
		length = (Q.rear - Q.front + SIZE) % SIZE;
}


void Enter(SqQueue& Q, ElmeType e)
{
	int len;
	getLength(Q, len);
	if (len == SIZE - 1)
		return;
	Q.elme[Q.rear] = e;
	if (Q.rear < SIZE - 1)
		Q.rear++;
	else
		Q.rear = 0;
}

void Remove(SqQueue& Q, ElmeType& e)
{
	if (Q.rear == Q.front)
		return;
	e = Q.elme[Q.front];
	if (Q.front < SIZE - 1)
		Q.front++;
	else
		Q.front = 0;
}